<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%@ include file="header.jsp"%>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Title</title>
</head>
<body>
<form method="post" id="formId">
    <table>
        <tr>
            <th>登陆名称</th>
            <td><input type="text"  name="name"></td>
        </tr>
        <tr>
            <th>密码</th>
            <td><input type="password" name="password"></td>
        </tr>
        <tr>
            <th>请输入验证码</th>
            <td><input type="text" name="code"><img src="${pageContext.request.contextPath}/getImage" alt=""></td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="button" value="提交" onclick="submitForm()"/>
            </td>
        </tr>
    </table>

</form>

<script type="text/javascript">
    function submitForm() {
        $.post(
            '/login',
            $('#formId').serialize(),
            function(jsonResult) {
                if (jsonResult.ok) {
                    mylayer.okUrl(jsonResult.msg, '/');
                } else {
                    mylayer.errorMsg(jsonResult.msg);
                }
            },
            'json'
        );
    }
</script>
</body>
</html>